package com.itqf.service.impl;

import com.itqf.dao.GoodsDao;
import com.itqf.dao.impl.GoodsDaoImpl;
import com.itqf.entity.Goods;
import com.itqf.entity.PageBean;
import com.itqf.service.GoodsService;

import java.sql.SQLException;
import java.util.List;

public class GoodsServiceImpl implements GoodsService {
    @Override
    public PageBean<Goods> findPage(int tid, int page, int pageSize) throws SQLException {
        GoodsDao goodsDao = new GoodsDaoImpl();
        long count = goodsDao.selectCountByTid(tid);
        List<Goods> list = goodsDao.selectGoodsByPage(page,pageSize,tid);
        return new PageBean<Goods>(list,page,pageSize,count);
    }

    @Override
    public Goods findGoodsByGid(int gid) throws SQLException {
        GoodsDao goodsDao = new GoodsDaoImpl();
        Goods goods = goodsDao.selectGoodsByGid(gid);
        return goods;
    }
}
